﻿
@{
    Layout = null;
}

<div class="page-btn text-center">
    <form action="#" id="pageForm">
        <a class="btn btn-default pagebtn" href="?pageNum=1&&sewhere=@ViewBag.search">首页</a>
        <a class="btn btn-default pagebtn" @(ViewBag.PageNum <= 1 ? "href=?pageNum=1 disabled=disabled" : "href=?pageNum=" + (ViewBag.PageNum - 1) +"&&sewhere="+ViewBag.search)>上一页</a>

        @{
            if (ViewBag.PageCount > 5)
            {
                if (ViewBag.PageNum > 1)
                {
                    <span>.....</span>
                }
                if (ViewBag.PageNum + 4 <= ViewBag.PageCount)
                {
                    for (int i = ViewBag.PageNum; i < ViewBag.PageNum + 5; i++)
                    {
                        <a class="btn btn-default pagebtn @(i == ViewBag.PageNum?"selectedPage":"")" href="?pageNum=@(i)&&sewhere=@ViewBag.search">@i</a>
                    }
                    if (ViewBag.PageNum + 4 < ViewBag.PageCount)
                    {
                        <span>.....</span>
                    }
                }
                else
                {
                    for (int i = ViewBag.PageCount - 4; i <= ViewBag.PageCount; i++)
                    {
                        <a class="btn btn-default pagebtn @(ViewBag.PageNum == i?"selectedPage":"")" href="?pageNum=@i&&sewhere=@ViewBag.search">@i</a>
                    }
                }
            }
            else
            {
                for (int i = 1; i <= ViewBag.PageCount; i++)
                {
                    <a class="btn btn-default pagebtn @(ViewBag.PageNum == i?"selectedPage":"")" href="?pageNum=@i&&sewhere=@ViewBag.search">@i</a>
                }
            }
        }

        <a class="btn btn-default pagebtn" @(ViewBag.PageNum >= ViewBag.PageCount ? "disabled=disabled" : "href=?pageNum=" + (ViewBag.PageNum + 1) +"&&sewhere="+ViewBag.search)>下一页</a>
        <a class="btn btn-default pagebtn" href="?pageNum=@ViewBag.PageCount&&sewhere=@ViewBag.search">尾页</a>
        &nbsp;&nbsp;&nbsp;
        <span>
            跳转到
        </span>
        <input class="page-input" style="color:#000;text-align:center;height:34px;width:40px;margin-top:3px;" type="number" min="1" max="@ViewBag.PageCount" name="pageNum" value="@ViewBag.PageNum" /> 页
        <input name="sewhere" value="@ViewBag.search" hidden="hidden" />
        <button class="btn btn-default pagebtn" type="submit" style="width:60px;">GO</button>
        <span>  
            共 @ViewBag.PageCount 页
        </span>
    </form>
</div>
